package com.luojing.springcloudalibaba.providerserver;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author luojing
 * @create 2018/11/21 9:32 AM
 **/
@SpringBootApplication
@EnableDiscoveryClient
public class Application {
  public static void main(String[] args) {
    SpringApplication.run(Application.class, args);
  }

  @RestController
  class EchoController {
    @RequestMapping(value = "/echo/{string}", method = RequestMethod.GET)
    public String echo(@PathVariable String string) {
      System.out.println("123");
      return string;
    }
  }

}

@Component
class ConfigRunner implements ApplicationRunner{
  @Value("${user.name}")
  String userName;

  @Value("${user.age}")
  int userAge;

  public void run(ApplicationArguments args) throws Exception {
    System.out.println(userName);
    System.out.println(userAge);
  }
}
